{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# AutoVizWidget\n",
    "\n",
    "This is a library that allows you to visualize a [Pandas DataFrame](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html) with a series of visualizations produced via [plotly](https://plot.ly/python/).\n",
    "\n",
    "The GUI displayed so that the user can easily select the features of the graph is produced via [ipywidgets](https://github.com/ipython/ipywidgets)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Creating a Pandas DataFrame\n",
    "\n",
    "We'll create a Pandas DataFrame to visualize."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df = pd.DataFrame({'a': [1,2,3], 'b': [1,2,3], 'c': [\"hi\",\"hello\",\"hey\"]})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Convenience methods\n",
    "\n",
    "You can let the library inspect your pandas DataFrame and select the X and Y axis automatically for you.\n",
    "Simply use the `display_dataframe` method:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from autovizwidget.widget.utils import display_dataframe\n",
    "\n",
    "display_dataframe(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![widget2](Capture1.PNG)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Specifying an encoding\n",
    "\n",
    "Alternatively, you can specify your own encoding by hand and then create a widget from it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Creating an Encoding\n",
    "\n",
    "Encodings is how we indicate to the library which features it will use to create visualizations declaratively.\n",
    "\n",
    "Below, we'll select column `c` as the X axis, column `b` as the Y axis, and we'll take the `min` of the `b` column when plotting against the `c` column."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from autovizwidget.widget.encoding import Encoding\n",
    "\n",
    "encoding = Encoding(chart_type=Encoding.chart_type_table, x='c', y='b', y_aggregation=Encoding.y_agg_min)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Visualizing\n",
    "\n",
    "We can now create an `AutoVizWidget` with our Pandas Dataframe (`df`) and the `encoding` we created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from autovizwidget.widget.autovizwidget import AutoVizWidget\n",
    "AutoVizWidget(df, encoding)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![widget2](Capture0.PNG)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  },
  "widgets": {
   "state": {
    "037bd2ab4f6d4314a38a2e80301ce7b4": {
     "views": []
    },
    "04c57693639047e7a5313d1af0ee8790": {
     "views": []
    },
    "05ff39de7d99409dbfd856766e17792d": {
     "views": []
    },
    "0df6a1ae4e7a469aa1d852385f8ab1eb": {
     "views": []
    },
    "1463eee9419f47df9d2ceb4e26c3d259": {
     "views": []
    },
    "1b1b4c3b337442fdb188f7974c9233a0": {
     "views": []
    },
    "2126d35079e54344ac76b4374ef0a3df": {
     "views": []
    },
    "2440163b60204ccbbdb2ec2334d66216": {
     "views": []
    },
    "29e0b9feb0694a5b8c4ee8f910242807": {
     "views": []
    },
    "2a06f61196964b21aee6489245da8879": {
     "views": []
    },
    "323d907b170f40e384376539ee35f6ff": {
     "views": []
    },
    "327636a5ecb2466c95c1174e02046924": {
     "views": []
    },
    "32c840a7b71740e2890f25114f8419c1": {
     "views": []
    },
    "34a101ec01604345afc8c87d5edc5b0b": {
     "views": []
    },
    "3529d4a4d3954a14a21c2ea1557c3f99": {
     "views": []
    },
    "37f47d04da8d4bf1a24f83aae75ea7df": {
     "views": []
    },
    "386e6d475c16483fa3da68cf68537fd2": {
     "views": []
    },
    "3b2972b2351247e59c22ca78bf5bbb03": {
     "views": []
    },
    "3e60599077414234a0b6501f30f7dd63": {
     "views": []
    },
    "3f59eee4fd094df7b7d0f9aa01a18914": {
     "views": []
    },
    "40e05aca5a684e169ecf1e74982b1c75": {
     "views": []
    },
    "43fc3d125b014abd85adfaefde4ce932": {
     "views": []
    },
    "45b8990f76ef47458289a27e377eba9a": {
     "views": []
    },
    "4d12c35815474feebe061e117a925c28": {
     "views": []
    },
    "4d9bd46400a245b1addf8c5cfa042b42": {
     "views": []
    },
    "5433b84ab7ad455ba5614714cffea9b8": {
     "views": []
    },
    "562cc50e4c424a81b94da7815ea9212e": {
     "views": []
    },
    "56409be397ac4ea6b9b258f421d88df4": {
     "views": []
    },
    "5f24f95a77684d4197659c707641cf45": {
     "views": []
    },
    "60db8a40732a4f6cb899fafddb3ba22a": {
     "views": []
    },
    "627fe1dfd3e34280b6a6d273f6e9eb20": {
     "views": []
    },
    "66fc0da02708416a96402d4c8108bdad": {
     "views": []
    },
    "6ae66bbf9b524f22a4dd14cea2032226": {
     "views": []
    },
    "6c94ff2b6d0645d6a0c3df2ee5fe82cc": {
     "views": []
    },
    "6fe604f3309244f8a974ab5a5ce3fee8": {
     "views": []
    },
    "712048c736ee448c8c371b50838165a4": {
     "views": []
    },
    "72baef41885d4c508c096419b8ca6304": {
     "views": []
    },
    "785972e6511547dfa1bc93de551b0dff": {
     "views": []
    },
    "78bead9954a84b66b8bebdadb2e15894": {
     "views": []
    },
    "7a9080b0630f4ff48f2086c908618c24": {
     "views": []
    },
    "7d1fd3d048ef484183c4f73f1d26d5d7": {
     "views": []
    },
    "7d9177cf9bac40daafdc40cb09b3497d": {
     "views": []
    },
    "7d9ecb97da584063bfe77ea9ac61313e": {
     "views": []
    },
    "86c8ed6625644fccbc57427c79ee1e12": {
     "views": []
    },
    "87e163c780d9433cba59206af42d42d0": {
     "views": []
    },
    "89677fe719ca44ebbef0c5a23265ea15": {
     "views": []
    },
    "8d9e94574c9346e18fba3c91ba842a8a": {
     "views": []
    },
    "952abb8e75ef4b46ab70ebcd7166c3e6": {
     "views": []
    },
    "965c211b8434455f80b0d13c981d8d3d": {
     "views": []
    },
    "976e02cb56114767a26acc867b73cf64": {
     "views": [
      {
       "cell_index": 4
      }
     ]
    },
    "9b0f51e0fac947c38e53601cb38cb6bd": {
     "views": []
    },
    "9ff34e8dec0c4d12ae6be3eff2049e50": {
     "views": []
    },
    "a1215a2879b04556a45d10997a2ecca2": {
     "views": []
    },
    "a185da1018b144c9a3352624e7a4af25": {
     "views": []
    },
    "a34b73b0a5174ce5aac0c95a6bf513f4": {
     "views": []
    },
    "a626bd61808e4e4e8defe14d985d3cab": {
     "views": []
    },
    "aca9990a7719414d9cdc68ec68e1e793": {
     "views": []
    },
    "b59f15f0577c46f09a434a7a4589be49": {
     "views": []
    },
    "b9fa825bcf9d4783801f61d243fdcf5e": {
     "views": []
    },
    "baeb3eeffe8a4600992f62e7d6f263f7": {
     "views": []
    },
    "bb87db31fb2747e7a39c4e8565352977": {
     "views": []
    },
    "bea2ddb1840c4c94adac554dbb91f21d": {
     "views": []
    },
    "bfc5874fe6914dadb2f90a3b959d4a75": {
     "views": []
    },
    "bfccfb1ff77f47e18dee7992a106a7f2": {
     "views": []
    },
    "c27795752fa846b29758fd5e760b08eb": {
     "views": []
    },
    "c3f61347086d4437aabd7033bb8f41f3": {
     "views": []
    },
    "c51930fedd97478eb1c26bcde29dcb53": {
     "views": []
    },
    "cbefe6c3f0424d6bb7b422a600e12088": {
     "views": []
    },
    "d11340ff706c4cbba5726752c2bd38c9": {
     "views": []
    },
    "e05db97c07414121a8e449e00200fb6b": {
     "views": [
      {
       "cell_index": 10
      }
     ]
    },
    "e52110af34af4ff0a458f770c43ce52b": {
     "views": []
    },
    "e5737cf1a4a44f40a335d66dcc1a3494": {
     "views": []
    },
    "e79e9d79face4d94b3b8a893af1e7cfa": {
     "views": []
    },
    "e7fa5c5277b24c6189a62e7ca8a1b3f2": {
     "views": []
    },
    "e81e0491962a4097b73922b6168186a7": {
     "views": []
    },
    "e8b3bbbbb6be4a2e88862e87293f1a0c": {
     "views": []
    },
    "ef6eb78cb2604963bfebec19e528a67e": {
     "views": []
    },
    "ef97f5d2f40c4cc9a23841e2e4a52ab7": {
     "views": []
    },
    "f0c6fb14473a48779e2d883b1049d839": {
     "views": []
    },
    "f2f04b8aba22434aa9fb5b8fdfd01796": {
     "views": []
    },
    "f68631be795542208a74cfe10000ba39": {
     "views": []
    },
    "fbc847264e0d4c799a46dd50d5c986d6": {
     "views": []
    },
    "fbcfdcefdca247749909f225d860b4e8": {
     "views": []
    },
    "fbe0a38a99d649b8858b62bef80eeeee": {
     "views": []
    },
    "fc990cf4d77c4b6195e337eaf5320636": {
     "views": []
    },
    "fde81f82120f4646ac2889b6807fbcbb": {
     "views": []
    },
    "fe6cb846a41c42a7bcfd16917323aaa4": {
     "views": []
    },
    "ff01218f991e41bfa51eeadef7321cbf": {
     "views": []
    }
   },
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
